<!--
 * @Description: 
 * @Author: william
 * @Date: 2025-08-22 15:54:57
 * @LastEditors: william
 * @LastEditTime: 2025-08-25 10:29:20
-->
<template>
  <view style="padding-top: 150rpx">
    <view class="page-body">
      <view class="page-section page-section-gap" style="text-align: center">
        <!-- <audio
          style="text-align: left"
          :src="current.src"
          :poster="current.poster"
          :name="current.name"
          :author="current.author"
          :action="audioAction"
          controls
        ></audio> -->
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      current: {
        poster: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/music-a.png',
        name: '致爱丽丝',
        author: '暂无',
        src: 'https://web-ext-storage.dcloud.net.cn/uni-app/ForElise.mp3'
      },
      audioAction: {
        method: 'pause'
      },
      utterThis: null
    }
  },
  mounted() {
    // this.utterThis = new SpeechSynthesisUtterance('hello world')

    // this.utterThis.pitch = 1 // 音高
    // this.utterThis.rate = 1 // 语速
    // this.utterThis.volume = 1 // 音量
    // this.utterThis.lang = 'zh-CN'
    // this.utterThis.text = '要播报的文本内容'
    // window.speechSynthesis.speak(this.utterThis) //开始朗读
    const innerAudioContext = uni.createInnerAudioContext()
    innerAudioContext.autoplay = true
    innerAudioContext.loop = false
    innerAudioContext.src =
      'https://web-ext-storage.dcloud.net.cn/uni-app/ForElise.mp3'
    innerAudioContext.onPlay(() => {
      console.log('开始播放')
    })
    innerAudioContext.onError(res => {
      console.log(res.errMsg)
      console.log(res.errCode)
    })
  }
}
</script>
